package com.youdianstar.app.common.widget.adapter

import android.content.Context
import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.youdianstar.app.common.util.ScreenUtil


/**
 * File: SpaceItemDecoration
 * Author: Administrator Create: 2024/7/4 0004 14:30
 * Changes (from 2024/7/4 0004)
 * --------------------------------------------------
 * description:
 * ---------------------------------------------------
 *
 */
class SpaceItemDecoration(
    private var mContext : Context,
    private var left: Int = 0,
    private var top: Int = 0,
    private var right: Int = 0,
    private var bottom: Int = 0
) : RecyclerView.ItemDecoration() {

    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
        super.getItemOffsets(outRect, view, parent, state)
        outRect.left = ScreenUtil.dp2px(mContext,left.toFloat()).toInt()
        outRect.right = ScreenUtil.dp2px(mContext,right.toFloat()).toInt()
        outRect.top = ScreenUtil.dp2px(mContext,top.toFloat()).toInt()
        outRect.bottom = ScreenUtil.dp2px(mContext,bottom.toFloat()).toInt()
    }
}